//Created by Roman Clarkson for Jaws.Core.Web
//Original work Copyright(C) 2008.  All Rights Reserved.

using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Jaws.Core.Web.Data;

namespace Jaws.Core.Web.Entities.Resources
{
    public class ResourceList : EntityListBase<ResourceList, Resource>, IXmlSerializable
    {
        public Resource this[string key]
        {
            get
            {
                for (int i = 0; i < base.Count; i++)
                {
                    if (base[i].Key == key)
                        return base[i];
                }
                return new Resource();
            }
            set
            {
                for (int i = 0; i < base.Count; i++)
                {
                    if (base[i].Key == key)
                    {
                        base[i] = value;
                        return;
                    }
                }
            }
        }

        #region IXmlSerializable Members

        public XmlSchema GetSchema()
        {
            throw new NotImplementedException();
        }

        public void ReadXml(XmlReader reader)
        {
            GetChildObjects(reader);
        }

        public void WriteXml(XmlWriter writer)
        {
            SaveChildObjects(writer);
        }

        #endregion
    }
}